package com.itheima.command;

import java.util.Set;

/**
 * @author zzw
 * @date 2025/10/25
 * @description 命令模式（具体命令类）
 */
public class OrderCommand implements Command {

    // 持有接收者对象
    private final SeniorChef seniorChef;
    private final Order order;

    public OrderCommand(SeniorChef seniorChef, Order order) {
        this.seniorChef = seniorChef;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "桌的订单：");
        Set<String> keys = order.getFoodDic().keySet();
        for (String key : keys) {
            seniorChef.makeFood(order.getFoodDic().get(key), key);
        }

        try {
            Thread.sleep(100);
        }
        catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }

        System.out.println(order.getDiningTable() + "桌的饭弄好了");
    }
}
